California Oil Spills

Spatial visualization of oil spill events in California.

Roshni Katrak-Adefowora true
02-25-2021

In this report, I explore oil spill incident tracking data in California in 2008. The data is provided by The California Department of Fish and Wildlife.

Initial Data Wrangling

hide
#Read in the data
oil_spill <- read_sf(here("_posts", "2021-02-25-oilspills", "oilspill","oilspill.shp")) %>% 
  clean_names()

ca_counties <- read_sf(here("_posts", "2021-02-25-oilspills", "ca_counties","CA_Counties_TIGER2016.shp"))

#check counties CRS
ca_counties %>% st_crs()

#check oil spill CRS
oil_spill %>% st_crs()

Creating the Interactive Map

hide
#set tmap to interactive mode
tmap_mode(mode = "view")

#make tmap
tm_shape(ca_counties) +
  tm_polygons()+
  tm_shape(oil_spill)+
  tm_dots()

Figure 1. Interactive map of oil spill events in California (2008).

Creating the Choropleth Map

hide
#join oil spill and CA
oil_spill_ca <- ca_counties %>% 
  st_join(oil_spill)

#inland oil spill counts
oil_spill_inland_counts <- oil_spill_ca %>% 
  filter(inlandmari == "Inland") %>% 
  count(localecoun)

#make choropleth
ggplot(data = oil_spill_inland_counts)+
  geom_sf(aes(fill = n), color = "white", size = 0.1)+
  scale_fill_gradientn(colors = c("#4558AE","#9D61DA", "#CF5AF2"))+
  theme_light()+
  labs(x = "Longitude",
       y = "Latitude",
       fill = "Number of oil spills")

Figure 2. Inland oil spills in each California county (2008).